package cn.stylefeng.guns.modular.transport.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.transport.entity.TransportDispatch;
import cn.stylefeng.guns.modular.transport.model.params.TransportDispatchParam;
import cn.stylefeng.guns.modular.transport.model.params.TransportReceiptParam;
import cn.stylefeng.guns.modular.transport.service.TransportDispatchService;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;


/**
 * 调度单表控制器
 */
@Controller
@RequestMapping("/transportDispatch")
public class TransportDispatchController extends BaseController {

    private String PREFIX = "/transport/transportDispatch";

    @Autowired
    private TransportDispatchService transportDispatchService;

    @Autowired
    private UserService userService;

    /**
     * 跳转到主页面
     */
    @RequestMapping("")
    public String index(TransportReceiptParam transportReceiptParam,Model model) {
    	model.addAttribute("transportReceiptParam", transportReceiptParam);
        return PREFIX + "/transportDispatch.html";
    }

    /**
     * 新增页面
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/transportDispatch_add.html";
    }

    /**
     * 编辑页面
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/transportDispatch_edit.html";
    }

    /**
     * 新增接口
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(TransportDispatchParam transportDispatchParam) {
        this.transportDispatchService.add(transportDispatchParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(TransportDispatchParam transportDispatchParam) {
        this.transportDispatchService.update(transportDispatchParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(TransportDispatchParam transportDispatchParam) {
        this.transportDispatchService.delete(transportDispatchParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(TransportDispatchParam transportDispatchParam) {
        TransportDispatch detail = this.transportDispatchService.getById(transportDispatchParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(TransportDispatchParam transportDispatchParam,String condition ,TransportReceiptParam transportReceiptParam) {
        return this.transportDispatchService.findPageBySpec(transportDispatchParam,condition,transportReceiptParam);
    }

}


